#This script is to compare the color consistency of a camera between 
#different colored backdrops 
import Image
import matplotlib

im1=Image.open('..\\..\\..\\..\\images\\cameraTests\\microsoftLifeCamVX6000\\birdblue.jpg')
im2=Image.open('..\\..\\..\\..\\images\\cameraTests\\microsoftLifeCamVX6000\\birdred.jpg')

box1=(180,226,280,312)  #the gray patch on the bird's body
im1Crop = im1.crop(box1);
im2Crop = im2.crop(box1);

red1, green1, blue1 = im1Crop.split()
red2, green2, blue2 = im2Crop.split()

red1, green1, blue1 = im1Crop.split()
red2, green2, blue2 = im2Crop.split()

red1Hist=red1.histogram()
green1Hist=green1.histogram()
blue1Hist=blue1.histogram()

red2Hist=red2.histogram()
green2Hist=green2.histogram()
blue2Hist=blue2.histogram()

matplotlib.pyplot.figure()
matplotlib.pyplot.plot(red1Hist,'r')
matplotlib.pyplot.hold(True)
matplotlib.pyplot.plot(red2Hist,'b')
matplotlib.pyplot.legend(('red background', 'blue background'))
matplotlib.pyplot.title('Comparing the red color channels',fontsize='xx-large')
matplotlib.pyplot.xlabel('pixel value',fontsize='xx-large')
matplotlib.pyplot.ylabel('# of pixels',fontsize='xx-large')
matplotlib.pyplot.xlim((0,255))


matplotlib.pyplot.figure()
matplotlib.pyplot.plot(green1Hist,'r')
matplotlib.pyplot.hold(True)
matplotlib.pyplot.plot(green2Hist,'b')
matplotlib.pyplot.legend(('red background', 'blue background'))
matplotlib.pyplot.title('Comparing the green color channels',fontsize='xx-large')
matplotlib.pyplot.xlabel('pixel value',fontsize='xx-large')
matplotlib.pyplot.ylabel('# of pixels',fontsize='xx-large')
matplotlib.pyplot.xlim((0,255))

matplotlib.pyplot.figure()
matplotlib.pyplot.plot(blue1Hist,'r')
matplotlib.pyplot.hold(True)
matplotlib.pyplot.plot(blue2Hist,'b')
matplotlib.pyplot.legend(('red background', 'blue background'))
matplotlib.pyplot.title('Comparing the blue color channels',fontsize='xx-large')
matplotlib.pyplot.xlabel('pixel value',fontsize='xx-large')
matplotlib.pyplot.ylabel('# of pixels',fontsize='xx-large')
matplotlib.pyplot.xlim((0,255))